<template>
  <div>
    <van-nav-bar
      title="添加收获地址"
      left-text="返回"
      left-arrow
      @click-left="edit"
    />
    <van-address-edit
      show-delete
      show-set-default
      :show-area="false"
      show-search-result
      :search-result="searchResult"
      @save="onSave"
      @change-detail="onChangeDetail"
    />
  </div>
</template>

<script>
export default {
  data() {
    return {
      searchResult: [],
    };
  },

  methods: {
    edit() {
      this.$router.replace("/address");
    },
    // 添加
    async onSave(content) {
      console.log(content);
      const res = await this.$post(this.url + "user/add/contect", {
        userId: this.$store.state.user.id,
        name: content.name,
        mobile: content.tel,
        address: content.addressDetail,
        contactFlag: content.isDefault ? 1 : 0,
      });
      if (res.errorCode == "0") {
        this.$notify("添加成功");
        this.$router.replace("/address");
      }
    },
    onChangeDetail() {},
    // onchange(value){
    //     this.
    // }
  },
};
</script>

<style  scoped>
</style>